//*************************************************************************
//  Author: Jocelyn Clancy      Date: 1/12/13
//
//  Allows you to enter values for A, B, and C to see what various values
//  will equal. A is the distance between the top of the arm to the
//  connection to the tether, B is the distance between the tether to the
//  pivot point, and C is the distance between the pivot point and the 
//  winch system.
//*************************************************************************
import java.util.Scanner;

public class ClimbingArm
{
    public static void main (String[] args)
    {
        double A, B, C;
        double h0, hF, theta0, thetaF, r0, rF, lift;
        int userInput = 1;

        Scanner scan = new Scanner(System.in);
        
        while (userInput == 1)
        {
            System.out.println ("Enter in a value for A:");
            A = scan.nextDouble();

            System.out.println ("Enter in a value for B:");
            B = scan.nextDouble();

            System.out.println ("Enter in a value for C:");
            C = scan.nextDouble();

            h0 = A + B;
            //Initial Angle is always 90 degrees.
            theta0 = Math.PI / 2;
            r0 = Math.sqrt(Math.pow(B, 2) + Math.pow(C, 2) + (2 * B * C * Math.cos(theta0)));

            thetaF = Math.acos(C/(A + B));
            hF = Math.sin(thetaF) * (A + B);
            rF = Math.sqrt(Math.pow(B, 2) + Math.pow(C, 2) - (2 * B * C * Math.cos(thetaF)));

            lift = h0 - hF;

            System.out.println ("Initial Height is: " + h0);
            System.out.println ("Initial Angle is: " + Math.toDegrees(theta0));
            System.out.println (String.format("Initial Rope Length is: %.3f" , r0));
            System.out.println ();
            System.out.println (String.format("Final Height is: %.3f" , hF));
            System.out.println (String.format("Final Angle is: %.3f" , Math.toDegrees(thetaF)));
            System.out.println (String.format("Final Rope Length is: %.3f" , rF));
            System.out.println ();
            System.out.println (String.format("Lift: %.3f" , lift));
            System.out.println ();
            
            System.out.println ("Would you like to enter different values? (enter 1 for yes and 0 for no)");
            userInput = scan.nextInt();
        }
    }
}